#include <stdio.h>
#include <stdarg.h>

int sum(int n, ...);

int sum(int n, ...)
{
	int i, sum = 0;
	va_list vap;
	
	va_start(vap, n);
	for (i = 0; i < n; i++)
	{
		sum += va_arg(vap, int);
	}
	va_end(vap);
	
	return sum;
}

int main()
{
	int result;
	
	result = sum(3, 11, 22, 33);
	printf("result = %d\n",result);

	result = sum(4, 11, 22, 33, 1);
	printf("result = %d\n",result);

	result = sum(5, 11, 22, 33, 1, -10);
	printf("result = %d\n",result);
	
	return 0;
}


